function getCookie(name)
{
	var cookieValue="";
	var search=name+"=";
	if(document.cookie.length>0)
	{
		offset=document.cookie.indexOf(search);
		if(offset!=-1)
		{
			offset+=search.length;
			end=document.cookie.indexOf(";",offset);
			if(end==-1)end=document.cookie.length;
			cookieValue=unescape(document.cookie.substring(offset,end));
		}
	}
	return cookieValue;
}

function setCookie(name,value)
{
	var expires=null;
	var argv=setCookie.arguments;
	var argc=setCookie.arguments.length;
	var hours=(argc>2)?argv[2]:null;
	var path=(argc>3)?argv[3]:null;
	//var domain=(argc>4)?argv[4]:null;
	var domain=".kkliao.net";
	var secure=(argc>5)?argv[5]:false;
	if(hours!=null)expires=new Date((new Date()).getTime()+hours*3600000);
	document.cookie=name+"="+value+((expires==null)?"":("; expires="+expires.toGMTString()))
	+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))
	+((secure==true)?"; secure":"");

	if(value != '')
	{
		var obj = document.getElementById("video_broadcast_title_id");
		if(obj)
		{
			window.setTimeout("last_call()",2000);
		}
	}
}

function last_call()
{
	//不需要再调PHP,直接更新HTML
	var url = "chat_room_status.php?clean=1&"+Math.random();
	$.get(url,function(data)
	{
		var obj = document.getElementById("video_broadcast_title_id");
		obj.innerHTML = data;
	});
}

function thisMovie(movieName)
{
	if (navigator.appName.indexOf('Microsoft') != -1)
	{
		return window[movieName];
	}
	else
	{
		return document[movieName];
	}
}

function swf_logout(jumpto)
{
	thisMovie('chat').fmsclose();
	setCookie('HS_PASSPORT','');
	setCookie('HS_V2','');
	if( jumpto == '' || jumpto == undefined )
	{
		jumpto = 'chat_room.php';
	}
	else
	{
		jumpto = encodeURI(jumpto);
	}
	location.href='logout.php?reference=' + jumpto;
}

function swf_close_fms()
{
	thisMovie('chat').fmsclose();
}
